<?php
/**
 * Admin Log definition 
 *
 * @author guzhi
 * @since 2009-04-15
 */

require_once BaseUtil::getModulePath("base")  .  '/services/BaseService.php';
require_once BaseUtil::getModulePath("acl")  .  '/models/AdminLogDao.php';

class AdminLogService extends BaseService {
	private $logDao;
	public function __contrust(){
		parent::__contrust();
		$this->logDao = new AdminLogDao();
		$this->logDao->setDb($this->db);
	}
	
    public function adminLog($uid, $action, $desc){
    	$log = array();
    	$log['admin_id'] = $uid;
    	$log['ip'] = $this->getIp();
    	$log['action'] = $action;
    	$log['result'] = $desc;
    	$logId = $this->logDao->addLog($log);
    }
    
    private function getIp(){
		if(getenv('HTTP_CLIENT_IP')){
		  $client_ip = getenv('HTTP_CLIENT_IP');
		}
		elseif(getenv('HTTP_X_FORWARDED_FOR')){
		  $client_ip = getenv('HTTP_X_FORWARDED_FOR');
		}
		elseif(getenv('REMOTE_ADDR')){
		  $client_ip = getenv('REMOTE_ADDR');
		}
		else{
		  $client_ip = $HTTP_SERVER_VAR['REMOTE_ADDR'];
		}
		return $client_ip;
	}
		
}


